package com.whut.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.whut.model.*;
import com.whut.service.AndroidService;
import com.whut.utils.FileUtil;
import com.whut.utils.FormatDate;
import com.whut.utils.UUIDGenerator;
import com.whut.webSocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author fuzhenjie
 */
@Controller
@RequestMapping("/android")
@Scope("prototype")
public class AndroidController {

    @Autowired
    private AndroidService androidService;

    //    设备印证模块
    @ResponseBody
    @PostMapping("/getEquipTypeNameList")
    public Object getEquipTypeNameList(String projectId) {
        return androidService.getEquipTypeNameList(projectId);
    }

    @ResponseBody
    @PostMapping("/getEquipNumList")
    public Object getEquipNumList(String projectId,String taskId, String equipType) {
        return androidService.getEquipNumList(projectId,taskId, equipType);
    }

    @ResponseBody
    @PostMapping("/getEquipSectionAndDescription")
    public Object getEquipSectionAndDescription(String equipType) {
        return androidService.getEquipSectionAndDescription(equipType);
    }

    @ResponseBody
    @PostMapping("/getEquipVerifyResuts")
    public Object getEquipVerifyResuts(String projectId, String equipType, String equipNum) {
        return androidService.getEquipVerifyResuts(projectId, equipType, equipNum);
    }


    /**
     * check the password isRight and return a json containing {isRight,data}
     *
     * @return java.lang.Object
     * @author fuzhenjie
     * @date 9:01 19.5.21
     * @Param [userPhone, password]
     **/
    @ResponseBody
    @PostMapping("/checkLogin")
    public Object checkLogin(String userPhone, String password) {
        System.out.println(userPhone + password);
        return androidService.checkPassword(userPhone, password);
    }

    /**
     * modify basic info of user except password
     *
     * @return java.lang.Object
     * @author fuzhenjie
     * @date 9:00 19.5.21
     * @Param [userinfo]
     **/
    @ResponseBody
    @PostMapping("/updateUserinfo")
    public Object checkLogin(Userinfo userinfo) {
        return androidService.modifyUserinfo(userinfo);
    }

    /**
     * update password
     *
     * @return java.lang.Object
     * @author fuzhenjie
     * @date 9:01 19.5.21
     * @Param [userId, newPwd, oldPwd]
     **/
    @ResponseBody
    @PostMapping("/updatePassword")
    public Object checkLogin(int userId, String newPwd, String oldPwd) {
        return androidService.modifyPwd(userId, newPwd, oldPwd);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * get teaminfo contains members
     * @date 9:16 19.5.21
     * @Param [userId]
     **/
    @ResponseBody
    @PostMapping("/getTeamInfo")
    public Object getTeamInfo(int userId) {
        return androidService.getGroupMemberDetail(userId);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * gettasks by userId => find teamid and find tasks //maybe unfinished?
     * @date 13:32 19.5.22
     * @Param [userId]
     **/
    @Deprecated
    @ResponseBody
    @PostMapping("/getTasks")
    public Object getTasks(int userId) {
        /* return androidService.getTasksByUserId(userId);*/
        return null;
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * getAllProjects
     * @date 14:03 19.5.22
     * @Param [curPage, pageSize]
     **/
    @ResponseBody
    @PostMapping("/getAllProjects")
    public Object getTasks(int curPage, int pageSize) {
        return androidService.getAllProjects(curPage, pageSize);
    }


    @ResponseBody
    @PostMapping("/pushTest")
    public Object addTaskByGroupHeader() {
        WebSocketServer.sendInfo("您有一条新的信息");
        return null;
    }


    /**
     * 通过userId 找出人员所属的所有小组Id，根据小组Id找出所有的周期
     *
     * @param userId
     * @return java.lang.Object
     * @author fuzhenjie
     * @date 19:54 19.5.22
     **/
    @ResponseBody
    @PostMapping("/getContractTaskAcceptList")
    public Object getContractTaskAcceptList(int userId) {
        System.out.println(userId);
        return androidService.getAllTaskAcceptList(userId);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * get 检查任务 by 周期id
     * @date 17:01 19.5.26
     * @Param [taskId]
     **/
    @ResponseBody
    @PostMapping("/getCCTList")
    public Object getCCTList(int taskId) {
        return androidService.getAllTaskAcceptList(taskId);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * get all contract not finished
     * @date 17:07 19.5.26
     **/
    @ResponseBody
    @PostMapping("/getContractList")
    @CrossOrigin("*")
    public Object getContractList() {
        return androidService.getAllContractUf();
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * //getSelfGroupList use for show the groupName for add Cycle
     * @date 18:10 19.5.26
     * @Param [userId]
     **/
    @ResponseBody
    @PostMapping("/getSelfGroupList")
    public Object getSelfGroupList(int userId) {
        return androidService.getSelfGroup(userId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * add cycle by params
     * @date 23:12 19.5.26
     * @Param [contracttaskaccept]
     **/
    @ResponseBody
    @PostMapping("/addCycle")
    public Object addCycle(Contracttaskaccept contracttaskaccept) {
        return androidService.addTaskAccept(contracttaskaccept);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * getTasksByCycle
     * @date 23:18 19.5.26
     * @Param [cycleId]
     **/
    @ResponseBody
    @PostMapping("/getTasksByCycle")
    public Object getTasksByCycle(int cycleId) {
        return androidService.getConChTaskListByTaskId(cycleId);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * getProjects  List ByCycle ID(taskId)
     * @date 9:12 19.5.27
     * @Param [cycleId]
     **/
    @ResponseBody
    @PostMapping("/getProjectsByCycle")
    public Object getProjectsByCycle(int contractId) {
        return androidService.getCTPByContractId(contractId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 新建检查计划，有可能需要从新建工程开始
     * @date 10:07 19.5.27
     * @Param [params]
     **/
    @ResponseBody
    @PostMapping("/addCheckTask")
    public Object addCheckTask(String params) {
        JSONObject jsonObject = JSONObject.parseObject(params);
        return androidService.addConTaskProject(jsonObject);
    }

    /**
     * @return java.lang.Object
     * @author lujialei
     * getSecByFirstName eg. firstName="新安全检查"
     * @Param [firstName]
     **/

    @ResponseBody
    @PostMapping("/getNewSecByFirstName")
    public Object getNewSecByFirstName(String firstName) {
        return androidService.getNewSecByFirstName(firstName);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * getSecByFirstName eg. firstName="安全检查"
     * @date 18:29 19.5.28
     * @Param [firstName]
     **/

    @ResponseBody
    @PostMapping("/getSecByFirstName")
    public Object getSecByFirstName(String firstName) {
        return androidService.getSecByFirstName(firstName);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过当前体系的number获取下一体系的列表
     * @date 19:38 19.5.29
     * @Param [firstName]
     **/
    @ResponseBody
    @PostMapping("/getNextSystemByNumber")
    public Object getNextSystemByNumber(int curNumber) {
        return androidService.getNextSystemByCurNum(curNumber);
    }

    /**
     * @return java.lang.Object
     * @author lujialei
     * 通过新表体系的number获取下一体系的列表
     * @date 19:38 19.5.29
     * @Param [firstName]
     **/
    @ResponseBody
    @PostMapping("/getNewNextSystemByNumber")
    public Object getNewNextSystemByNumber(int curNumber) {
        return androidService.getNewNextSystemByCurNum(curNumber);
    }

    /*添加的新实测实量的一个数据*/
    @ResponseBody
    @PostMapping("/getNewMeasureTableChooseByNumber")
    public Object getNewMeasureTableChooseByNumber(int curNumber) {
        return androidService.getNewNextMeasureTableChooseByNumber(curNumber);
    }

    @ResponseBody
    @PostMapping("/getNewLastMeasureTableChooseByNumber")
    public Object getNewLastMeasureTableChooseByNumber(int curNumber) {
        return androidService.getNewLastMeasureTableChooseByNumber(curNumber);
    }

    @ResponseBody
    @PostMapping("/getNewNextLastMeasureTableChooseByNumber")
    public Object getNewNextLastMeasureTableChooseByNumber(int curNumber) {
        return androidService.getNewNextLastMeasureTableChooseByNumber(curNumber);
    }


    @ResponseBody
    @PostMapping("/newMeasureCalculate")
    public Object newMeasureCalculate(String data) {
        return androidService.newMeasureCalculate(data);
    }


    @ResponseBody
    @PostMapping("/newMeasureAddPointValue")
    public Object newMeasureAddPointValue(Newmeasureresulttmp data) {
        return androidService.newMeasureAddPointValue(data);
    }

    @ResponseBody
    @PostMapping("/withDrawResult")
    public Object withDrawResult(String resultTypeId) {
        return androidService.withDrawResult(resultTypeId);
    }

    @ResponseBody
    @PostMapping("/getQfPoints")
    public Object getQfPoints(String resultTypeId) {
        return androidService.getQfPoints(resultTypeId);
    }


    @ResponseBody
    @PostMapping("/getMeasurePointValues")
    public Object getMeasurePointValues(String resultTypeId) {
        return androidService.getMeasurePointValues(resultTypeId);
    }

    @ResponseBody
    @PostMapping("/getAllResult")
    public Object getAllResult(String resultTypeId) {
        return androidService.getAllResult(resultTypeId);
    }

    @ResponseBody
    @PostMapping("/getHasResult")
    public Object getHasResult(String resultTypeId) {
        return androidService.getHasResult(resultTypeId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过第六级编号找问题描述
     * @date 14:34 19.5.30
     * @Param [preNum]
     **/
    @ResponseBody
    @PostMapping("/getProbDesByPreNum")
    public Object getProbDesByPreNum(int preNum) {
//        System.out.println(preNum);
//        System.out.println(JSON.toJSON(androidService.getProblemDesListBySixNum(preNum)));
        return androidService.getProblemDesListBySixNum(preNum);
    }

    /**
     * @return java.lang.Object
     * @author lujialei
     * 通过新表第六级编号找问题描述
     * @date 14:34 19.5.30
     * @Param [preNum]
     **/
    @ResponseBody
    @PostMapping("/getNewProbDesByPreNum")
    public Object getNewProbDesByPreNum(int preNum) {
//        System.out.println(preNum);
//        System.out.println(JSON.toJSON(androidService.getProblemDesListBySixNum(preNum)));
        return androidService.getNewProblemDesListBySixNum(preNum);
    }

    @ResponseBody
    @PostMapping("/addSingleCheck")
    public Object addSingleCheck(String params, List<MultipartFile> files) {
        System.out.println(params);
        Resultsinglechild resultsinglechild = JSON.toJavaObject(JSONObject.parseObject(params), Resultsinglechild.class);
        System.out.println(resultsinglechild);

        System.out.println(files.size());

        String absolutePath = "";
        JSONArray imgs = new JSONArray();
        try {
            for (int i = 0; i < files.size(); i++) {
                String fileName = UUIDGenerator.generateUUID() + ".png";
                absolutePath = FileUtil.upload(files.get(i).getInputStream(), "img/", fileName);
                imgs.add(fileName);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        resultsinglechild.setPicPath(absolutePath);
        resultsinglechild.setPicFileName(imgs.toJSONString());
        return androidService.addResultSingleChild(resultsinglechild);

    }

    @ResponseBody
    @PostMapping("/addEquipVerifyResut")
    public Object addEquipVerifyResut(String params, List<MultipartFile> files) {
        System.out.println(params);
        EquipVerifyResult equipVerifyResult = JSON.toJavaObject(JSONObject.parseObject(params), EquipVerifyResult.class);
        System.out.println(equipVerifyResult);
        System.out.println(files.size());
        //        定义的上传服务器的地方
        String absolutePath = "";
        JSONArray imgs = new JSONArray();
        try{
            for (int i = 0; i < files.size(); i++) {
                String fileName = UUIDGenerator.generateUUID() + ".png";
                absolutePath = FileUtil.upload(files.get(i).getInputStream(), "img/", fileName);
                imgs.add(fileName);
            }
        }catch (IOException e){
            e.printStackTrace();
        }

        equipVerifyResult.setPicPath(absolutePath);
        equipVerifyResult.setPicFileName(imgs.toJSONString());
        return androidService.addEquipVerifyResult(equipVerifyResult);


    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 根据userId和checkId 获取每个人单次任务的检查项列表
     * @date 16:45 19.6.1
     * @Param [checkId, userId]
     **/
    @ResponseBody
    @PostMapping("/getPersonalSingleCheckList")
    public Object getPersonalSingleCheckList(int checkId, int userId) {
        return androidService.getPersonalSingleCheckList(checkId, userId);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 这个方法是为了从problemCollect中取得检查过的项目的列表（直到第四级）
     * @date 13:46 19.6.2
     * @Param [curNumber]
     **/
    @ResponseBody
    @PostMapping("/getSystemNextListFromProColl")
    public Object getSystemNextListFromProColl(int curNumber, int checkId, int type) {
        return androidService.getSystemNextListFromProColl(checkId, curNumber, type);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 每个人单独将自己所检察的部分合并到problemCollect
     * @date 14:17 19.6.2
     * @Param [checkId, userId]
     **/
    @ResponseBody
    @PostMapping("/doPersonalMerge")
    public Object doPersonalMerge(int checkId, int userId) {
        return androidService.doPersonalMerge(checkId, userId);
    }

    /**
     * 将设备检查的进行生成，而不进行合并
     * @param checkId
     * @param userId
     * @return
     */
    @ResponseBody
    @PostMapping("/doPersonalMergeOnly")
    public Object doPersonalMergeOnly(int checkId, int userId) {
        return androidService.doPersonalMergeOnly(checkId, userId);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过第四季体系的编号和checkId来获取排除掉的列表
     * @date 21:11 19.6.2
     * @Param [checkId, fourthId]
     **/
    @ResponseBody
    @PostMapping("/getUncheckedSixthList")
    public Object getUncheckedSixthList(int checkId, int fourthId) {
        return androidService.getUncheckedSixthList(fourthId, checkId);
    }
    /**
     * @author Lei
     * @description 在这个地方排除
     * @date 16:17 2021/4/12
     * @params [checkId, fourthId]
     * @return java.lang.Object
     */
    @ResponseBody
    @PostMapping("/getNewUncheckedSixthList")
    public Object getNewUncheckedSixthList(int checkId, int fourthId) {
        return androidService.getNewUncheckedSixthList(fourthId, checkId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 提交各个排除项
     * @date 22:30 19.6.2
     * @Param [params]
     **/
    @ResponseBody
    @PostMapping("/updateUnsubmit")
    public String updateUnsubmit(String params) {
        JSONObject jsonObject = JSONObject.parseObject(params);
        return androidService.updateUnsubmit(jsonObject);
    }

    /**
     * 将某次检查的某个fourthId设为加到resultProblemCollect中
     *
     * @param noproblemitem
     * @return java.lang.String
     * @author fuzhenjie
     * @date 19.9.21 13:43(GMT)
     */
    @ResponseBody
    @PostMapping("/fourthAllNoProblem")
    public String fourthAllNoProblem(Noproblemitem noproblemitem) {
        return androidService.addNoProblem(noproblemitem);
    }

    /**
     * @return java.lang.String
     * @author fuzhenjie
     * 将CCT表的完成状态更新
     * @date 14:38 19.6.28
     * @Param [checkId]
     **/
    @ResponseBody
    @PostMapping("/updateFinishState")
    public String updateFinishState(int checkId) {
        return androidService.updateFinishState(checkId);
    }


    /**
     * @return java.lang.String 返回值是"Y" or "N"
     * @author fuzhenjie
     * 通过userId和组的id来判断是否是这个小组的组长
     * @date 14:37 19.6.28
     * @Param [userId, groupId]
     **/
    @ResponseBody
    @PostMapping("/getIsHead")
    public String getIsHead(int userId, int groupId) {
        return androidService.getIsHead(userId, groupId);
    }

    /**
     * @param userId
     * @return
     */
    @ResponseBody
    @PostMapping("/getIsYJLUser")
    public String getIsYJLUser(int userId) {
        return androidService.getIsYJLUser(userId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 添加签名
     * @date 14:39 19.6.28
     * @Param [checkId, files]
     **/
    @ResponseBody
    @PostMapping("/addSignature")
    public Object addSignature(int checkId, List<MultipartFile> files) {
        System.out.println(checkId);
        System.out.println(files.size());
        //String path = FileUtil.getServerFolderPath();
        String absolutePath = "";
        JSONArray imgs = new JSONArray();
        try {
            for (int i = 0; i < files.size(); i++) {
                String fileName = FormatDate.getDateStringYMDHms1() + FormatDate.getFormatNumber000(i + 1) + ".png";
                absolutePath = FileUtil.upload(files.get(i).getInputStream(), "signature/", fileName);
                imgs.add(fileName);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        ContractCheckTask contractchecktask = new ContractCheckTask();
        contractchecktask.setCheckId(checkId);
        contractchecktask.setSignPath(absolutePath);
        contractchecktask.setJsSign(imgs.getString(0));
        contractchecktask.setJlSign(imgs.getString(1));
        contractchecktask.setSgSign(imgs.getString(2));
        return androidService.saveSigs(contractchecktask);

    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * a method to test singleton and prototype
     * @date 16:59 19.6.8
     * @Param [index]
     **/
    @ResponseBody
    @PostMapping("/scopeTest")
    public Object addSignature(int index) {
        Thread thread = Thread.currentThread();
        System.out.println("Thread ID: " + thread.getId());
        System.out.println("code:" + this.hashCode());
        return index * index * index;
    }

    /**
     * @return java.lang.String
     * @author fuzhenjie
     * 获取检查项目的完成状态 返回"Y"or"N"
     * @date 10:08 19.6.9
     * @Param [checkId]
     **/
    @ResponseBody
    @PostMapping("/getIsFinished")
    public String getIsFinished(int checkId) {
        return androidService.getIsCheckFinished(checkId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过工程号得到工程所有的设备列表
     * @date 10:10 19.6.9
     * @Param [projectId]
     **/
    @ResponseBody
    @PostMapping("/getDeviceListByProjectId")
    public Object getDeviceListByProjectId(int projectId) {
        return androidService.getDeviceListByProjectId(projectId);
    }

    /**
     * @return java.lang.String
     * @author fuzhenjie
     * 通过设备Id删除一条设备记录
     * @date 10:26 19.6.9
     * @Param [equipId]
     **/
    @ResponseBody
    @PostMapping("/deleteDevice")
    public String deleteDevice(int equipId) {
        return androidService.deleteDeviceInfoByEquipId(equipId);
    }

    /**
     * @return java.lang.String
     * @author fuzhenjie
     * 更新equipInfo
     * @date 10:27 19.6.9
     * @Param [equipinfo]
     **/
    @ResponseBody
    @PostMapping("/modifyDevice")
    public String modifyDevice(Equipinfo equipinfo) {
        return androidService.updateDeviceInfo(equipinfo);
    }

    /**
     * @return java.lang.String
     * @author fuzhenjie
     * 添加一条设备信息
     * @date 14:53 19.6.9
     * @Param [Equipinfo]
     **/
    @ResponseBody
    @PostMapping("/addDeviceInfo")
    public String addDeviceInfo(Equipinfo equipinfo) {
        return androidService.addDeviceInfo(equipinfo);
    }


    @ResponseBody
    @PostMapping("/checkUpdate")
    public Object checkUpdate(String currentVersion) {
        return androidService.getUpdate(currentVersion);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过第四级Id 与 checkId 来找到problemCollect中的检查项列表
     * @date 14:56 19.6.14
     * @Param [checkId, fourthId]
     **/
    @ResponseBody
    @PostMapping("/getTeamLeaderExamineList")
    public Object getTeamLeaderExamineList(int checkId, int fourthId) {
        return androidService.getTLExamineList(checkId, fourthId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过problemCollect中的mkey从problemCollectDetail中找到一条详细的记录，并附带有选择项,用以初始化
     * @date 19:22 19.6.17
     * @Param [mkey]
     **/
    @ResponseBody
    @PostMapping("/getTeamLeaderModifyIniInfo")
    public Object getTeamLeaderModifyIniInfo(int mkey) {
        return androidService.getTeamLeaderModifyIniInfo(mkey);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 将一条记录根据mkey从problemCollect中删除
     * @date 19:24 19.6.17
     * @Param [mkey]
     **/
    @ResponseBody
    @PostMapping("/deleteProbCollRecordByMkey")
    public String deleteProbCollRecordByMkey(int mkey) {
        return androidService.delProbCollRecord(mkey);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 修改一条problemCollect中的记录
     * @date 19:25 19.6.17
     * @Param
     **/
    @ResponseBody
    @PostMapping("/modifyProbCollRecord")
    public String modifyProbCollRecord(Problemcollect problemcollect) {
        System.out.println(JSON.toJSONString(problemcollect));
        return androidService.updateProbCollInfo(problemcollect);
    }

    /**
     * @return java.lang.String
     * @author fuzhenjie
     * 获取最新版本app的下载二维码 返回二维码图片的资源链接
     * @date 10:52 19.6.19
     * @Param []
     **/
    @ResponseBody
    @PostMapping("/getQRCode")
    public String getQRCode() {
        return androidService.getLatestVersionQRcode();
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 找到一个用户所有resultsinglechild中的项 ，通过其checkId找到 有关的CCT（检查）
     * @date 15:12 19.6.19
     * @Param [userId, curPage, pageSize]
     **/
    @ResponseBody
    @PostMapping("/getPersonalCheckList")
    public Object getPersonalCheckList(int userId, int curPage, int pageSize) {
        return androidService.getPersonalCheckList(userId, curPage, pageSize);
    }

    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过用户Id和检查Id 找到检查过(resultsinglechild中已经置Y)的项列表（不需分页）
     * @date 15:13 19.6.19
     * @Param [userId, checkId]
     **/
    @ResponseBody
    @PostMapping("/getPersonalSubmittedItemsByCheckId")
    public Object getPersonalSubmittedItemsByCheckId(int userId, int checkId) {
        return androidService.getPerSIByCheckId(userId, checkId);
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 通过mkey查找某条已经提交的resultsinglechild记录
     * @date 19:25 19.6.19
     * @Param [mkey]
     **/
    @ResponseBody
    @PostMapping("/getSubmittedItemDetail")
    public Object getSubmittedItemDetail(int mkey) {
        return androidService.getRSCDetail(mkey);
    }


    @ResponseBody
    @PostMapping("/updateVersion")
    public String updateVersion(String validation, String version) {
        if ("fzjFzj".equals(validation)) {
            return androidService.updateAPPVersion(version);
        } else {
            return "validation denied!!!!!!!!! ----- by fzj";
        }
    }


    /**
     * @return java.lang.Object
     * @author fuzhenjie
     * 取得该成员（组长）所在小组的检查项目列表（分页）
     * @date 15:24 19.6.25
     * @Param [userId, curPage, pageSize]
     **/
    @ResponseBody
    @PostMapping("/getSignListByPage")
    public Object getSignListByPage(int userId, int curPage, int pageSize) {
        return androidService.getSignListByUserId(userId, curPage, pageSize);
    }


    /*methods following is some example methods*/

    /*@Deprecated
    @ResponseBody
    @PostMapping("/getUser")
    public Object getUser(String id){
        System.out.println(id);
        return userService.getUserById(Integer.parseInt(id));
    }

    @Deprecated
    @ResponseBody
    @PostMapping("/addUser")
    public Object getUser(Userinfo userinfo){
        //System.out.println(id);
        System.out.println(userinfo);
        return userService.addUser(userinfo);
    }


    @Deprecated
    @ResponseBody
    @PostMapping("/getMultiParams")
    public Object getMultiParams(String params, List<MultipartFile> files){
        String imgRootPath = "C:\\Users\\13983\\Desktop\\test";
        File dir = new File(imgRootPath);
        if (!dir.exists()){
            dir.mkdirs();
        }
        try {
            System.out.println(111);
            for (int i = 0;i<files.size();i++) {
                String fileName = imgRootPath+"\\"+i+".jpg";
                File file = new File(fileName);
                files.get(i).transferTo(file);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
        System.out.println(params);
        return null;
    }

    @Deprecated
    @ResponseBody
    @PostMapping("/getGroupMembers")
    public Object getGroupMembers(){
        return userService.getAllMembers(1,10);
    }

    @Deprecated
    @ResponseBody
    @RequestMapping("/getCount")
    public Integer getCount(){
        return androidService.getCount();
    }*/

    /*---wxd---start---*/

    /**
     * @author: wxd
     * @Description: 根据第四级id、项目id和taskId查询抽样设备编号
     * @date: 2020-06-23 18:57:37
     * @param:
     */
    @ResponseBody
    @PostMapping("/requestCheckPartList")
    public Object requestCheckPartList(int projectId, int taskId, int curNumber) {
        return androidService.getEquipNumByCurNum(projectId, taskId, curNumber);
    }

    /**
     * @author: wxd
     * @Description: 根据项目id、第一级id、第四级id、userId查询个人已检查过的设备编号
     * @date: 2020-06-23 18:59:10
     * @param:
     */
    @ResponseBody
    @PostMapping("/requestCheckedParts")
    public Object requestCheckedParts(int projectId, int firstId, int fourthId, int checker) {
        return androidService.getEquipNumByChecker(projectId, firstId, fourthId, checker);
    }

    /**
     * @author: wxd
     * @Description: 根据项目id查询抽样设备
     * @date: 2020-07-04 15:43:46
     * @param:
     */
    @ResponseBody
    @PostMapping("/getSampleEquipByProjectId")
    public Object getSampleEquipByProjectId(int projectId) {
        return androidService.getSampleEquipByProjectId(projectId);
    }

    /*
     * @author: wxd
     * @Description: 获取组长审核时检查项目第三级和第四级内容
     * @date: 2020/9/9 20:00
     * @param: [checkId]
     */
    @ResponseBody
    @PostMapping("/requestThirdListAll")
    public Object requestThirdListAll(int checkId) {
        return androidService.requestThirdListAll(checkId);
    }
    /*---wxd----end----*/

    /***
     * @auther lyl
     * 相似度接口
     * @date 18:11 2020/10/31
     * @param
     * @return
     */
    @ResponseBody
    @PostMapping("/getMatchingText")
    public List<Word2VecSystem> requestGetMatchingText(String text) {
        List<Word2VecSystem> resList = androidService.getMatchingText(text);
        return resList;
    }

    /**
     * @param
     * @return
     * @auther lyl
     * //分词接口
     * @date 18:26 2020/11/5
     */
    @ResponseBody
    @PostMapping("/segmentSentence")
    public String segmentSentence(String text) {
        return androidService.segmentSentence(text);
    }
}
